package com.shinhye.mobilelottery.net.protocol;

import org.apache.commons.lang3.StringUtils;
import org.xmlpull.v1.XmlSerializer;

/**
 * 叶子信息封装
 * @author ShinHye
 * 2014-9-22 下午3:49:07
 */
public class Leaf {
	private String name;
	private String value;

	public Leaf(String name) {
		super();
		this.name = name;
	}

	public Leaf(String name, String value) {
		super();
		this.name = name;
		this.value = value;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public void serializer(XmlSerializer serializer) {
		if (StringUtils.isBlank(name)) {
			throw new RuntimeException("Tag is null.");
		}

		try {
			serializer.startTag(null, name);
			if (StringUtils.isBlank(value))
				value = "";
			serializer.text(value);
			serializer.endTag(null, name);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}